#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H

#include <wx/wxprec.h>
#include <set>
#include <editor_hooks.h>

class cbStyledTextCtrl;

class Highlighter {
  public:
    Highlighter( std::set<wxString> &texts );
    virtual ~Highlighter();
    void Call( M_Code_Editor*, wxScintillaEvent& ) const;

    const int     GetIndicator()      const;
    const wxColor GetIndicatorColor() const;
    void          TextsChanged()      const;

  private:
    void OnEditorChange( M_Code_Editor* ctrl )   const;
    void OnEditorUpdateUI( M_Code_Editor *ctrl ) const;

    void ClearAllIndications( M_Code_StyledTextCtrl* stc )const;
    void ClearAllIndications()const;
    void DoSetIndications( M_Code_Editor* ctrl )const;
    void OnEditorChangeTextRange( M_Code_Editor* ctrl, int start, int end )const;
    void HighlightOccurrencesOfSelection( M_Code_Editor* ctrl )const;

    std::set<wxString>&           m_Texts;
    mutable bool                  m_AlreadyChecked;
    mutable M_Code_Editor*             m_OldCtrl;
    mutable wxArrayInt            m_InvalidatedRangesStart;
    mutable wxArrayInt            m_InvalidatedRangesEnd;
    mutable std::pair<long, long> m_HighlightSelectedOccurencesLastPos;
    mutable M_Code_StyledTextCtrl*     m_OldHighlightSelectionCtrl;
};

#endif
